#include "structMesh_testFunctions.hpp"
#include "meshTypeFunctions.hpp"

RectMesh makeRectMesh(Index m, Index n, scalar dx, scalar dy){
	return uniMeshAs<RectMesh>( {m, n}, {dx, dy}, {0, 0} );
}

RectMesh makeRectMesh( Array2i size, Array2s diff, Array2s orig ){
	return uniMeshAs<RectMesh>(size, diff, orig);
}

RectMesh createRectMesh() {
	VectorXs xCoords{4};
	VectorXs yCoords{5};

	xCoords << 0.0, 0.5, 1.5, 3.0;

	yCoords << 0.0, 1.5, 2.0, 3.0, 5.0;

	return { std::move(xCoords), std::move(yCoords)};
}

StructMesh makeStructMesh(Index m, Index n, scalar dx, scalar dy){
	return uniMeshAs<StructMesh>( {m, n}, {dx, dy}, {0, 0} );
}

StructMesh makeStructMesh( Array2i size, Array2s diff, Array2s orig ){
	return uniMeshAs<StructMesh>(size, diff, orig);
}

StructMesh createStructMesh(){
	Matrix2Xs vertices(2, 4*4);

	vertices.col(0)  = Vector2s{0  , 0};
	vertices.col(1)  = Vector2s{1  , 0.4};
	vertices.col(2)  = Vector2s{1.8, 0.2};
	vertices.col(3)  = Vector2s{2.8, 0.1};
	vertices.col(4)  = Vector2s{0  , 0.8};
	vertices.col(5)  = Vector2s{1  , 1.6};
	vertices.col(6)  = Vector2s{2.4, 1.6};
	vertices.col(7)  = Vector2s{2.6, 1.2};
	vertices.col(8)  = Vector2s{0.2, 2.2};
	vertices.col(9)  = Vector2s{1.2, 1.8};
	vertices.col(10) = Vector2s{1.8, 2};
	vertices.col(11) = Vector2s{3.2, 2};
	vertices.col(12) = Vector2s{0  , 2.8};
	vertices.col(13) = Vector2s{1  , 2.8};
	vertices.col(14) = Vector2s{2.2, 2.8};
	vertices.col(15) = Vector2s{3.2, 2.8};

	return { std::move(vertices), 3, 3 };
}

hms::StructMesh createTrueStructMeshForMpi() {
	Matrix2Xs vertices (2, 7*8);

	vertices.col(0 ) = Vector2s{ 1.0  , 0.0 };
	vertices.col(1 ) = Vector2s{ 4.0  , 0.0 };
	vertices.col(2 ) = Vector2s{ 6.0  , 0.0 };
	vertices.col(3 ) = Vector2s{ 8.0  , 0.0 };
	vertices.col(4 ) = Vector2s{ 9.0  , 0.0 };
	vertices.col(5 ) = Vector2s{ 12.0 , 0.0 };
	vertices.col(6 ) = Vector2s{ 14.0 , 0.0 };
	vertices.col(7 ) = Vector2s{ 2.0  , 2.0 };
	vertices.col(8 ) = Vector2s{ 4.0  , 2.0 };
	vertices.col(9 ) = Vector2s{ 5.0  , 2.0 };
	vertices.col(10) = Vector2s{ 7.0  , 2.0 };
	vertices.col(11) = Vector2s{ 9.0  , 1.0 };
	vertices.col(12) = Vector2s{ 11.0 , 2.0 };
	vertices.col(13) = Vector2s{ 14.0 , 3.0 };
	vertices.col(14) = Vector2s{ 2.0  , 4.0 };
	vertices.col(15) = Vector2s{ 3.0  , 4.0 };
	vertices.col(16) = Vector2s{ 5.5  , 3.5 };
	vertices.col(17) = Vector2s{ 7.0  , 4.0 };
	vertices.col(18) = Vector2s{ 9.0  , 3.0 };
	vertices.col(19) = Vector2s{ 11.0 , 3.0 };
	vertices.col(20) = Vector2s{ 14.0 , 5.0 };
	vertices.col(21) = Vector2s{ 1.0  , 6.0 };
	vertices.col(22) = Vector2s{ 3.0  , 5.0 };
	vertices.col(23) = Vector2s{ 5.0  , 5.0 };
	vertices.col(24) = Vector2s{ 7.0  , 5.0 };
	vertices.col(25) = Vector2s{ 9.0  , 6.0 };
	vertices.col(26) = Vector2s{ 11.0 , 5.0 };
	vertices.col(27) = Vector2s{ 13.0 , 7.0 };
	vertices.col(28) = Vector2s{ 1.0  , 8.0 };
	vertices.col(29) = Vector2s{ 3.0  , 8.0 };
	vertices.col(30) = Vector2s{ 6.0  , 8.0 };
	vertices.col(31) = Vector2s{ 7.0  , 8.0 };
	vertices.col(32) = Vector2s{ 8.0  , 8.0 };	
	vertices.col(33) = Vector2s{ 11.0 , 8.0 };
	vertices.col(34) = Vector2s{ 13.0 , 8.0 };
	vertices.col(35) = Vector2s{ 0.0  , 10.0 };
	vertices.col(36) = Vector2s{ 2.0  , 11.0 };
	vertices.col(37) = Vector2s{ 4.0  , 12.0 };
	vertices.col(38) = Vector2s{ 7.0  , 11.0 };
	vertices.col(39) = Vector2s{ 8.0  , 11.0 };	
	vertices.col(40) = Vector2s{ 10.0 , 10.5 };
	vertices.col(41) = Vector2s{ 15.0 , 11.0 };
	vertices.col(42) = Vector2s{ 0.0  , 15.0 };
	vertices.col(43) = Vector2s{ 2.0  , 14.0 };
	vertices.col(44) = Vector2s{ 5.0  , 15.0 };
	vertices.col(45) = Vector2s{ 7.0  , 16.0 };
	vertices.col(46) = Vector2s{ 10.0 , 16.0 };
	vertices.col(47) = Vector2s{ 12.0 , 15.5 };
	vertices.col(48) = Vector2s{ 16.0 , 16.0 };
	vertices.col(49) = Vector2s{ 0.0  , 19.0 };
	vertices.col(50) = Vector2s{ 2.0  , 19.0 };
	vertices.col(51) = Vector2s{ 5.0  , 19.0 };
	vertices.col(52) = Vector2s{ 7.0  , 19.0 };
	vertices.col(53) = Vector2s{ 10.0 , 19.0 };
	vertices.col(54) = Vector2s{ 12.0 , 19.0 };
	vertices.col(55) = Vector2s{ 16.0 , 19.0 };

	return { std::move(vertices), 6, 7 };
}

hms::RectMesh createTrueRectMeshForMpi(){
	VectorXs xCoords{11};
	VectorXs yCoords{11};

	xCoords << 0, 2, 4, 6, 10, 14, 15, 16, 19, 21, 24;
	yCoords << 0, 2, 6, 8, 9, 13, 15, 18, 19 ,20, 23;

	return { std::move(xCoords), std::move(yCoords) };
}
